package com.cfx.exercise_40;

import java.util.Random;
import java.util.Scanner;

public class TestThread1 extends Thread{
	static boolean flag = false;
	public static void main(String[] args) {
	
		Thread t1 = new Thread(){
			public void run(){
				Random r = new Random();
				while(!flag){
					System.out.println(r.nextInt(100));//打印100以内的随机数
				}
			}
			
		};
		Thread t2 = new Thread(){
			public void run(){
				Scanner s = new Scanner(System.in);
				System.out.println("输入Q结束");
				String string = s.nextLine();
				if("q".equalsIgnoreCase(string)){
					flag = true;
				}
			}
		};
		t1.start();
		t2.start();
		
	}
}
